package com.luoqiz.project.qq.client.threads;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.Socket;

import com.luoqiz.project.qq.client.ChatJFrame;


public class ChatThread extends Thread {

	private Socket socket;
	private ChatJFrame chatJFrame;

	public ChatThread(ChatJFrame chatJFrame, Socket socket) {
		this.socket = socket;
		this.chatJFrame = chatJFrame;
	}

	@Override
	public void run() {
		byte[] b = new byte[1024];
		BufferedInputStream bin = null;
		try {
			bin = new BufferedInputStream(socket.getInputStream());
			int len = -1;
			while ((len = bin.read(b)) != -1) {
				String s = new String(b, 0, len);
				chatJFrame.msgContentJta.append(s+"\r\n");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
